#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <sys/types.h>
int main()
{
	pid_t id = fork();
	if(id<0)
	{
		perror("fork fail");
		exit(1);
	}
	if(id == 0)
	{
		//child
		printf("i am a child pid:%d\n",getpid());
		sleep(20);
		exit(10);
	}
	else
	{
		//father
		int status;
		int ret = wait(&status);
		if(ret>0&&(status&0x7F)==0)
		{
			//normal exit
			printf("child exit code:%d\n",(status>>8)&0xFF);

		}
		else if(ret>0)
		{
			printf("sig code:%d\n",status&0x7F);
		}


	}


	return 0;
}

